package cn.jiyun.controller;

import cn.jiyun.pojo.User;
import cn.jiyun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/user")
@RestController
public class UserController {
    @Resource
    private UserService userService;


    @GetMapping("{id}")
    public User findById(@PathVariable Long id) {
        //System.out.println(Truth);
        return userService.findById(id);
    }

    @GetMapping("all")
    public List<User> all(){
        return userService.all();
    }
    @PostMapping("/del")
    public void  del(Long id){
        userService.del(id);
    }

    @PostMapping("/add")
    public void add(@RequestBody User user){
        userService.add(user);
    }


}
